dojo.provide('jetty.Location');

dojo.declare('jetty.Location', null, {
  constructor: function(request) {
    this.host     = ph.str(request.getHeader('Host'));
    this.hostname = this.host.replace(/:.+$/, '');
    this.pathname = ph.str(request.getRequestURI());
    this.port     = parseInt(this.host.replace(/^.+?:/, ''), 10);
    this.protocol = ph.str(request.getScheme()) + ':';
    this.search   = '?' + ph.str(request.getQueryString() || '');
    this.href     = ph.str(request.getRequestURL()) + this.search;
  },
  
  toString: function() {
    return this.href;
  }
});
